﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using System.Data;
using BrokerBase.Lib.Tool;
using System.IO;
using System.Xml;
using Broker.Update;

namespace Broker.Model
{
    public class ScoreInfo
    {
        public static long LoadMax(ISession sess)
        {
            string sql = "select ifNUll(max(ts),0) from Score_ScoreRecord";

            IDbCommand cmd = sess.Connection.CreateCommand();

            cmd.CommandText = sql;

            long ts = (long)cmd.ExecuteScalar();

            return ts;
        }

        public static void UpdateScoreRecord(dynamic data,ISession sess)
        {
            DataUpdateManager mgr = new DataUpdateManager();

            
//            string s = TransportUtil.DecompressText(data);
//            StringReader sr = new StringReader(s);

//            XmlTextReader reader = new XmlTextReader(sr);
//            DataSet ds = new DataSet("Score_ScoreRecord");

//            ds.ReadXml(reader, XmlReadMode.ReadSchema);


//            string sql = @"insert into Score_ScoreRecord(Id,RecordType,OppositeLevel,IsTrial,Score,ScoreTime,Description,Ts,Direction 
//                            Values(?,?,?,?,?,?,?,?,?)";



//            foreach (DataRow dr in ds.Tables[0].Rows)
//            {

//            }

        }

        public virtual int Id { get; set; }

        public virtual string RecordType { get; set; }

        public virtual int Direction { get; set; }

        public virtual int OppositeLevel { get; set; }

        public virtual bool IsTrial { get; set; }

        public virtual double Score { get; set; }

        public virtual DateTime ScoreTime { get; set; }

        public virtual string Description { get; set; }

        public virtual long Ts { get; set; }
    }
}
